<template>
  <entity-view
    :operator-type="operatorType"
    :model="beanInfo"
    @submit="submitDst"
    :rules="rules"
    ref="form"
  >
    <div class="sub-content-flex">
      <form-item
        label="通道标识"
        v-model="beanInfo.dstChannelId"
        prop="dstChannelId"
        disabled
      ></form-item>
      <form-item
        label="通道类型"
        v-model="beanInfo.dstChannelType"
        prop="dstChannelType"
        disabled
      ></form-item>
      <form-item
        label="通道类型描述"
        v-model="beanInfo.dstChannelTypeDesc"
        prop="dstChannelTypeDesc"
      ></form-item>
      <form-item
        label="渠道号"
        v-model="beanInfo.channelNo"
        prop="channelNo"
      >
      </form-item>
      <form-item
        label="服务商商户号"
        v-model="beanInfo.providerMchntNo"
        prop="providerMchntNo"
      ></form-item>
      <form-item
        label="主APPID"
        v-model="beanInfo.appId"
        prop="appId"
      ></form-item>
      <form-item
        label="子APPID"
        v-model="beanInfo.subAppId"
        prop="subAppId"
      ></form-item>
    </div>
  </entity-view>
</template>
<script>
import EntityView from "../../../../components/common/entityView/EntityView.vue";
import FormItem from "../../../../components/common/entityView/FormItem.vue";

export default {
  name: "PDstChannelCfgOperation",
  components: {
    EntityView,
    FormItem,
  },
  props: {
    query: Object,
  },
  data: function () {
    return {
      modalDstTitle: "",
      operatorType: "edit",
      modalDstVisible: true,
      beanInfo: {
        dstChannelName:"",
        dstChannelType:"",
        dstChannelTypeDesc:"",
        channelNo:"",
        providerMchntNo:"",
        appId:"",
        subAppId:"",

      },
      rules: {
        dstChannelTypeDesc: [{ required: true, message: "必输", trigger: "blur" }],
      },
      loading: false,
      pageInfo: {},
    };
  },
  methods: {
    async submitDst() {
      let res;
      switch (this.operatorType) {
        case "edit":
          res = await this.edit();
          break;
        case "view":
          res = true;
          break;
        default:
          break;
      }
      return res;
    },
    async edit() {
      const res = await this.$refs.form.validate();
      if (res) {
        const params = this.beanInfo;
        params['optFlag']= "upd";
        const res = await this.$put(
          "/admin/igas/pDstChannelCfg/update",
          params
        );
        if (res.status === 200) {
          this.$message.success("保存成功！");
          return true;
        } else {
          this.$message.error(res.data.message);
          return false;
        }
      }
    },
    setOperatorType(type) {
      this.operatorType = type;
    },
    setBeanInfo(beanInfo) {
      this.beanInfo = beanInfo;
    },
  },
};
</script>

<style lang="less" scoped>
@import "../../../../../static/less/Common";
.subtitle {
  width: 100%;
  font-size: 18px;
  margin-bottom: 10px;
}
.sub-content-flex {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
}
.sub-content-block {
  display: block;
  flex-wrap: wrap;
  width: 100%;
}
</style>
